package com.twu.biblioteca.command;

import com.twu.biblioteca.model.Borrowable;
import com.twu.biblioteca.domain.Library;
import com.twu.biblioteca.model.Movie;

import java.util.List;

public class ListMoviesCommand extends Command {
    private Library library;

    public ListMoviesCommand(Library library) {
        this.library = library;
    }

    @Override
    public String execute() {
        String listMovies = "list movies\n";
        List<Borrowable> movies = library.getAllMovies();
        for (Borrowable borrowable : movies) {
            Movie movie = (Movie) borrowable;
            String listMovie = movie.getId() + "\t" + movie.getName() + "\t" + movie.getYear() + "\t" + movie.getDirector() + "\t" + movie.getMovieRating() + "\n";
            listMovies += listMovie;
        }
        return listMovies;
    }
}
